home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-strunb.ads < prev    next >
Text File  |  1996-01-30  |  10KB  |  346 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . U N B O U N D E D                 --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.9 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18.  
  19. with Ada.Strings.Maps;
  20.  
  21. package Ada.Strings.Unbounded is
  22. pragma Preelaborate (Unbounded);
  23.  
  24.    type Unbounded_String is private;
  25.  
  26.    Null_Unbounded_String : constant Unbounded_String;
  27.  
  28.    function Length (Source : Unbounded_String) return Natural;
  29.  
  30.    type String_Access is access all String;
  31.  
  32.    procedure Free (X : in out String_Access);
  33.  
  34.    --------------------------------------------------------
  35.    -- Conversion, Concatenation, and Selection Functions --
  36.    --------------------------------------------------------
  37.  
  38.    function To_Unbounded_String (Source : String)     return Unbounded_String;
  39.    function To_Unbounded_String (Length : in Natural) return Unbounded_String;
  40.  
  41.    function To_String (Source : Unbounded_String) return String;
  42.  
  43.    procedure Append
  44.      (Source   : in out Unbounded_String;
  45.       New_Item : in Unbounded_String);
  46.  
  47.    procedure Append
  48.      (Source   : in out Unbounded_String;
  49.       New_Item : in String);
  50.  
  51.    procedure Append
  52.      (Source   : in out Unbounded_String;
  53.       New_Item : in Character);
  54.  
  55.    function "&" (Left, Right : Unbounded_String) return Unbounded_String;
  56.  
  57.    function "&"
  58.      (Left  : in Unbounded_String;
  59.       Right : in String)
  60.       return  Unbounded_String;
  61.  
  62.    function "&"
  63.      (Left  : in String;
  64.       Right : in Unbounded_String)
  65.       return  Unbounded_String;
  66.  
  67.    function "&"
  68.      (Left  : in Unbounded_String;
  69.       Right : in Character)
  70.       return  Unbounded_String;
  71.  
  72.    function "&"
  73.      (Left  : in Character;
  74.       Right : in Unbounded_String)
  75.       return  Unbounded_String;
  76.  
  77.    function Element
  78.      (Source : in Unbounded_String;
  79.       Index  : in Positive)
  80.       return   Character;
  81.  
  82.    procedure Replace_Element
  83.      (Source : in out Unbounded_String;
  84.       Index  : in Positive;
  85.       By     : Character);
  86.  
  87.    function Slice
  88.      (Source : in Unbounded_String;
  89.       Low    : in Positive;
  90.       High   : in Natural)
  91.       return   String;
  92.  
  93.    function "=" (Left, Right : in Unbounded_String) return Boolean;
  94.  
  95.    function "="
  96.      (Left  : in Unbounded_String;
  97.       Right : in String)
  98.       return  Boolean;
  99.  
  100.    function "="
  101.      (Left  : in String;
  102.       Right : in Unbounded_String)
  103.       return  Boolean;
  104.  
  105.    function "<" (Left, Right : in Unbounded_String) return Boolean;
  106.  
  107.    function "<"
  108.      (Left  : in Unbounded_String;
  109.       Right : in String)
  110.       return  Boolean;
  111.  
  112.    function "<"
  113.      (Left  : in String;
  114.       Right : in Unbounded_String)
  115.       return  Boolean;
  116.  
  117.    function "<=" (Left, Right : in Unbounded_String) return Boolean;
  118.  
  119.    function "<="
  120.      (Left  : in Unbounded_String;
  121.       Right : in String)
  122.       return  Boolean;
  123.  
  124.    function "<="
  125.      (Left  : in String;
  126.       Right : in Unbounded_String)
  127.       return  Boolean;
  128.  
  129.    function ">" (Left, Right : in Unbounded_String) return Boolean;
  130.  
  131.    function ">"
  132.      (Left  : in Unbounded_String;
  133.       Right : in String)
  134.       return  Boolean;
  135.  
  136.    function ">"
  137.      (Left  : in String;
  138.       Right : in Unbounded_String)
  139.       return  Boolean;
  140.  
  141.    function ">=" (Left, Right : in Unbounded_String) return Boolean;
  142.  
  143.    function ">="
  144.      (Left  : in Unbounded_String;
  145.       Right : in String)
  146.       return  Boolean;
  147.  
  148.    function ">="
  149.      (Left  : in String;
  150.       Right : in Unbounded_String)
  151.       return  Boolean;
  152.  
  153.    ------------------------
  154.    -- Search Subprograms --
  155.    ------------------------
  156.  
  157.    function Index
  158.      (Source   : in Unbounded_String;
  159.       Pattern  : in String;
  160.       Going    : in Direction := Forward;
  161.       Mapping  : in Maps.Character_Mapping := Maps.Identity)
  162.       return     Natural;
  163.  
  164.    function Index
  165.      (Source   : in Unbounded_String;
  166.       Pattern  : in String;
  167.       Going    : in Direction := Forward;
  168.       Mapping  : in Maps.Character_Mapping_Function)
  169.       return     Natural;
  170.  
  171.    function Index
  172.      (Source : in Unbounded_String;
  173.       Set    : in Maps.Character_Set;
  174.       Test   : in Membership := Inside;
  175.       Going  : in Direction  := Forward)
  176.       return   Natural;
  177.  
  178.    function Index_Non_Blank
  179.      (Source : in Unbounded_String;
  180.       Going  : in Direction := Forward)
  181.       return   Natural;
  182.  
  183.    function Count
  184.      (Source  : in Unbounded_String;
  185.       Pattern : in String;
  186.       Mapping : in Maps.Character_Mapping := Maps.Identity)
  187.       return    Natural;
  188.  
  189.    function Count
  190.      (Source   : in Unbounded_String;
  191.       Pattern  : in String;
  192.       Mapping  : in Maps.Character_Mapping_Function)
  193.       return     Natural;
  194.  
  195.    function Count
  196.      (Source : in Unbounded_String;
  197.       Set    : in Maps.Character_Set)
  198.       return   Natural;
  199.  
  200.    procedure Find_Token
  201.      (Source : in Unbounded_String;
  202.       Set    : in Maps.Character_Set;
  203.       Test   : in Membership;
  204.       First  : out Positive;
  205.       Last   : out Natural);
  206.  
  207.    ------------------------------------
  208.    -- String Translation Subprograms --
  209.    ------------------------------------
  210.  
  211.    function Translate
  212.      (Source  : in Unbounded_String;
  213.       Mapping : in Maps.Character_Mapping)
  214.       return    Unbounded_String;
  215.  
  216.    procedure Translate
  217.      (Source  : in out Unbounded_String;
  218.       Mapping : Maps.Character_Mapping);
  219.  
  220.    function Translate
  221.      (Source  : in Unbounded_String;
  222.       Mapping : in Maps.Character_Mapping_Function)
  223.       return    Unbounded_String;
  224.  
  225.    procedure Translate
  226.      (Source  : in out Unbounded_String;
  227.       Mapping : in Maps.Character_Mapping_Function);
  228.  
  229.    ---------------------------------------
  230.    -- String Transformation Subprograms --
  231.    ---------------------------------------
  232.  
  233.    function Replace_Slice
  234.      (Source : in Unbounded_String;
  235.       Low    : in Positive;
  236.       High   : in Natural;
  237.       By     : in String)
  238.       return   Unbounded_String;
  239.  
  240.    procedure Replace_Slice
  241.      (Source   : in out Unbounded_String;
  242.       Low      : in Positive;
  243.       High     : in Natural;
  244.       By       : in String);
  245.  
  246.    function Insert
  247.      (Source   : in Unbounded_String;
  248.       Before   : in Positive;
  249.       New_Item : in String)
  250.       return     Unbounded_String;
  251.  
  252.    procedure Insert
  253.      (Source   : in out Unbounded_String;
  254.       Before   : in Positive;
  255.       New_Item : in String);
  256.  
  257.    function Overwrite
  258.      (Source   : in Unbounded_String;
  259.       Position : in Positive;
  260.       New_Item : in String)
  261.       return     Unbounded_String;
  262.  
  263.    procedure Overwrite
  264.      (Source    : in out Unbounded_String;
  265.       Position  : in Positive;
  266.       New_Item  : in String);
  267.  
  268.    function Delete
  269.      (Source  : in Unbounded_String;
  270.       From    : in Positive;
  271.       Through : in Natural)
  272.       return    Unbounded_String;
  273.  
  274.    procedure Delete
  275.      (Source  : in out Unbounded_String;
  276.       From    : in Positive;
  277.       Through : in Natural);
  278.  
  279.    function Trim
  280.      (Source : in Unbounded_String;
  281.       Side   : in Trim_End)
  282.       return   Unbounded_String;
  283.  
  284.    procedure Trim
  285.      (Source : in out Unbounded_String;
  286.       Side   : in Trim_End);
  287.  
  288.    function Trim
  289.      (Source : in Unbounded_String;
  290.       Left   : in Maps.Character_Set;
  291.       Right  : in Maps.Character_Set)
  292.       return   Unbounded_String;
  293.  
  294.    procedure Trim
  295.      (Source : in out Unbounded_String;
  296.       Left   : in Maps.Character_Set;
  297.       Right  : in Maps.Character_Set);
  298.  
  299.    function Head
  300.      (Source : in Unbounded_String;
  301.       Count  : in Natural;
  302.       Pad    : in Character := Space)
  303.       return   Unbounded_String;
  304.  
  305.    procedure Head
  306.      (Source : in out Unbounded_String;
  307.       Count  : in Natural;
  308.       Pad    : in Character := Space);
  309.  
  310.    function Tail
  311.      (Source : in Unbounded_String;
  312.       Count  : in Natural;
  313.       Pad    : in Character := Space)
  314.       return   Unbounded_String;
  315.  
  316.    procedure Tail
  317.      (Source : in out Unbounded_String;
  318.       Count  : in Natural;
  319.       Pad    : in Character := Space);
  320.  
  321.    function "*"
  322.      (Left  : in Natural;
  323.       Right : in Character)
  324.       return  Unbounded_String;
  325.  
  326.    function "*"
  327.      (Left  : in Natural;
  328.       Right : in String)
  329.       return  Unbounded_String;
  330.  
  331.    function "*"
  332.      (Left  : in Natural;
  333.       Right : in Unbounded_String)
  334.       return  Unbounded_String;
  335.  
  336. private
  337.  
  338.    type Unbounded_String is record
  339.       Reference : String_Access := new String'("");
  340.    end record;
  341.  
  342.    Null_Unbounded_String : constant Unbounded_String :=
  343.                              (Reference => new String'(""));
  344.  
  345. end Ada.Strings.Unbounded;
  346.